#include "pcapdev.h"
#include <QDebug>

CPCapAddr::CPCapAddr(QObject *parent) : QObject(parent)
{
    qDebug("[CAddrInfo]constructed");
}

CPCapAddr::~CPCapAddr()
{
    qDebug("[CAddrInfo]destroyed");
}

QString CPCapAddr::ip() const
{
    return m_ip;
}

QString CPCapAddr::netmask() const
{
    return m_netmask;
}

QString CPCapAddr::broadcast() const
{
    return m_broadcast;
}

QString CPCapAddr::dstaddr() const
{
    return m_dstaddr;
}

void CPCapAddr::setIp(const QString &ip)
{
    m_ip = ip;
}

void CPCapAddr::setNetmask(const QString &netmask)
{
    m_netmask = netmask;
}

void CPCapAddr::setBroadcast(const QString &broadcast)
{
    m_broadcast = broadcast;
}

void CPCapAddr::setDstaddr(const QString &dstaddr)
{
    m_dstaddr = dstaddr;
}

CPCapDev::CPCapDev(QObject *parent) : QObject(parent)
{
    qDebug("[CDevInfo]constructed");
}

CPCapDev::~CPCapDev()
{
    qDebug("[CDevInfo]destroyed");
    clear_addrs();
}

QString CPCapDev::source() const
{
    return m_source;
}

QString CPCapDev::description() const
{
    return m_description;
}

QQmlListProperty<CPCapAddr> CPCapDev::addrs()
{
    return QQmlListProperty<CPCapAddr>(this, m_addrs);
}

void CPCapDev::setSource(const QString &source)
{
    m_source = source;
}

void CPCapDev::setDescription(const QString &description)
{
    m_description = description;
}

void CPCapDev::apendAddr(CPCapAddr *addr)
{
    m_addrs.append(addr);
}

void CPCapDev::clear_addrs()
{
    foreach (CPCapAddr *addr, m_addrs) {
        delete addr;
    }
    m_addrs.clear();
}
